<template>
  <laker-dialog
    v-model="visible"
    :title="dataModel.fullFileName"
    width="900"
    :show-fullscreen="true"
    :show-close="true"
    @closed="$emit('closed')"
  >
    <div v-loading="loading">
      <el-image :src="fileUrl" lazy />
    </div>
  </laker-dialog>
</template>

<script>
import LakerDialog from '@/components/lakerDialog/index.vue'
import isepApi from '@/api/isep'

export default {
  name: 'HikImgView',
  components: { LakerDialog },
  data() {
    return {
      dialog: {
        dic: false,
        info: false
      },
      mode: 'add',
      titleMap: {
        add: '文件预览'
      },
      loading: false,
      visible: false,
      type: '',
      fileUrl: '',
      srcList: [],
      dataModel: {
        bucketName: '',
        fileName: '',
        fullFileName: '文件预览',
        fileExtension: '',
        businessId: '',
        fileUrl: ''
      },
      excel: {
        // 数据
        workbook: {},
        // 表名称集合
        sheetNames: [],
        // 激活项
        sheetNameActive: '',
        // 当前激活表格
        SheetActiveTable: ''
      }
    }
  },
  mounted() {},
  methods: {
    //显示
    open(mode = 'add') {
      this.mode = mode
      this.visible = true
      return this
    },
    close() {
      this.visible = false
      return this
    },
    setData(params) {
      Object.assign(this.dataModel, params)
      this.initFileData()
    },
    updateDataModel(obj) {
      Object.assign(this.dataModel, obj)
    },
    async initFileData() {
      this.loading = true
      isepApi.getFileByteArray(this.dataModel).then((data) => {
        if (data) {
          let blob = new Blob([data], { type: 'image/jpeg' })
          this.fileUrl = URL.createObjectURL(blob)
          console.log(this.fileUrl)
          this.loading = false
        }
      })
    }
  }
}
</script>

<style>
.default-table {
  width: 100% !important;
  border-collapse: collapse !important;
  border-spacing: 0 !important;
  text-align: center !important;
  border: 0px !important;
  overflow-x: auto !important;
}

.default-table tr td {
  /* border: 1px solid gray !important; */
  border-right: 1px solid gray !important;
  border-bottom: 1px solid gray !important;
  width: 200px !important;
  height: 33px !important;
}
</style>
